package com.gy.api.mobile.msg.service.impl;

import cn.hutool.core.util.IdUtil;
import com.gy.api.base.Constants;
import com.gy.api.mobile.msg.dao.UserMessagesDao;
import com.gy.api.mobile.msg.domain.po.UserMessagesPO;
import com.gy.api.mobile.msg.domain.vo.MessageResDto;
import com.gy.api.mobile.msg.service.IUserMessageService;
import com.gy.api.pc.examine.dao.ExamineDao;
import com.gy.api.pc.examine.dao.ExamineLogDao;
import com.gy.api.pc.examine.domain.po.ExamineLogPO;
import com.gy.api.pc.examine.domain.po.ExaminePO;
import com.gy.api.pc.examine.domain.vo.ExamineAddVO;
import com.gy.api.pc.examine.domain.vo.ExamineLogAddVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;


@Service
@Transactional
@Slf4j
public class UserMessageServiceImpl implements IUserMessageService {

    @Autowired
    UserMessagesDao messagesDao;

    @Override
    public List<MessageResDto> getList(String loginIdAsString) {
        return messagesDao.getList(loginIdAsString);
    }

    @Override
    public void handle(List<String> messageIdList) {
        for (String id:messageIdList) {
            UserMessagesPO userMessagesPO= messagesDao.selectByPrimaryKey(id);
            userMessagesPO.setIsHandle(1);
            messagesDao.updateByPrimaryKeySelective(userMessagesPO);
        }
    }

    @Override
    public void delete(List<String> messageIdList) {
        for (String id:messageIdList) {
            messagesDao.deleteByPrimaryKey(id);
        }
    }

    @Override
    public MessageResDto detail(String messageId) {
        UserMessagesPO userMessagesPO= messagesDao.selectByPrimaryKey(messageId);
        MessageResDto messageResDto=new MessageResDto();
        BeanUtils.copyProperties(userMessagesPO, messageResDto);
        return messageResDto;
    }
}